<style lang="scss" scoped>
@import "@/assets/css/variable";

.detail {
  width: 100%;
  background-color: $bgw;
  min-height: 100%;
  font-size: 1.2rem;
  overflow: hidden;
  flex: 1;
  box-sizing: border-box;
  .backIcon{
  	position: fixed;
  	top: 5px;
  	left: 10px;
	z-index: 1;
	display: flex;
	align-items: center;
	color:white;
	padding: 4px 8px;
	padding-right: 12px;
	border-radius: 6px;
	background-color: rgba($color: #000000, $alpha: 0.7);
  }
  .headerImg {
    box-sizing: border-box;
    width: 100%;
    height: 160px;
    overflow: hidden;
  }
  .info {
    display: flex;
    flex-direction: column;
    padding: 0 1.6rem 1rem 1.6rem;
    .line1 {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 1rem 0;
      .title {
        font-size: 1.7rem;
        color: $color1;
      }
      .badge {
        padding: 0.3rem 0.8rem;
        font-size: 1.2rem;
        background-color: rgba(#ff7e16, 0.2);
        color: #ff7e16;
        // border: 0.1rem solid #FF6D00;
        border-radius: 0.3rem;
        box-sizing: border-box;
        overflow: hidden;
      }
      .badge3 {
        padding: 0.3rem 0.8rem;
        font-size: 1.2rem;
        transform: scale(0.8);
        background-color: #e4eaff;
        color: #4970fd;
        border-radius: 0.3rem;
        box-sizing: border-box;
        overflow: hidden;
      }
      .badge1 {
        padding: 0.3rem 0.8rem;
        font-size: 1.2rem;
        transform: scale(0.8);
        background-color: #ffecdc;
        color: #ff7e16;
        border-radius: 0.3rem;
        box-sizing: border-box;
        overflow: hidden;
      }
      .badge2 {
        padding: 0.3rem 0.8rem;
        font-size: 1.2rem;
        background-color: #e8e9e9;
        color: #999;
        border-radius: 0.3rem;
        box-sizing: border-box;
        overflow: hidden;
      }
    }
    .line2 {
      display: flex;
      align-items: center;
      justify-content: myInfo;
      color: $color2;
      .text {
        font-size: 1.3rem;
        margin-left: 0.6rem;
      }
      .text2 {
        font-size: 1.3rem;
        margin-left: 0.6rem;
        color: $adornColor;
      }
    }
  }
}
.content {
  padding: 1.4rem 1.6rem;

  .title2 {
    font-size: 1.6rem;
    color: $color2;
    font-weight: bold;
  }
  .line {
    margin-top: 1.2rem;
    font-size: 1.3rem;
    .label {
      color: #999;
    }
    .value {
      color: #777;
      margin-left: 1.2rem;
      line-height: 1.6rem;
    }
  }
  .line3 {
    margin-top: 1.2rem;
    // font-size: 1.3rem;
    border-bottom: 1px solid #f4f4f4;
    padding-bottom: 1rem;
    .label {
      color: #999;
    }
    .title {
      font-size: 1.6rem;
      font-weight: bold;
      color: $color2;
    }
    .value {
      color: #777;
      margin-top: 1.2rem;
      letter-spacing: 1px;
    }
  }
  .line4 {
    margin-top: 1.2rem;
    font-size: 1.3rem;
    padding-bottom: 1rem;
    .title {
      font-size: 1.6rem;
      color: $color2;
      font-weight: bold;
    }
    .item {
      padding: 2.8rem 1.2rem 1.2rem 1.2rem;
      background-color: white;
      box-shadow: 0 0 1px 1px #f4f4f4;
      border-radius: 0.8rem;
      margin-top: 3rem;
      position: relative;
      .image {
        position: absolute;
        left: 1.2rem;
        top: -1.7rem;
      }
      .name {
        font-size: 1.5rem;
        color: $color1;
      }
      .desc {
        margin-top: 0.8rem;
        color: $color3;
        font-size: 1.1rem;
        line-height: 1.6rem;
        letter-spacing: 1px;
      }
    }
  }
	.line5 {
    margin-top: 1.2rem;
    font-size: 1.3rem;
    padding-bottom: 1rem;
		.title {
			font-size: 1.6rem;
      color: #191F25;
      font-weight: bold;
		}
		.item {
      padding: 0 1.2rem 1.2rem 0rem;
      background-color: white;
      border-radius: 0.8rem;
      margin-top: 1rem;
			display: flex;
			.img {
				flex: 0 0 3.4rem;
			}
			.rightBox{
				display: flex;
				flex-direction: column;
				.fotn {
					flex: 1;
					margin-left: 1rem;
					.name {
						font-family: Source Han Sans CN;
						font-style: normal;
						font-weight: normal;
						font-size: 14px;
						line-height: 20px;
						color: rgba(25, 31, 37, 0.56);
						margin-bottom: 3px;
					}
					.desc {
						font-family: Source Han Sans CN;
						font-style: normal;
						font-weight: normal;
						font-size: 14px;
						line-height: 20px;
						/* or 143% */
						color: #191F25;
					}
					.icon {
						position: absolute;
						right: 3rem;
						.img {
							float: right;
							width: 1.5rem;
							height: 1.5rem;
						}
						.fontIcon{
							padding-left: .5rem;
							float: right;
							color: #4970FD;
							width: 2rem;
							height: 2rem;
							line-height: 2rem;
						}
					}
				}
				.huifu {
					position: relative;
					margin-left: .5rem;
					margin-top: 1rem;
					border-radius: 7px;
					padding: 1rem;
					box-sizing: border-box;
					background: rgba(73, 112, 253, 0.15);
					.huifuNames {
						display: flex;
							.huifuName {
								/* 弹出框标题、表格标题 */
								font-family: Source Han Sans CN;
								font-style: normal;
								font-weight: normal;
								font-size: 1.3rem;
								line-height: 2rem;
								/* identical to box height, or 143% */
								color: rgba(25, 31, 37, 0.56);
								margin-bottom: .5rem;
							}
						.userIncon {
							margin-left: 5px;
							width: 2rem;
							height: 2rem;
						}
					}
					.huifuComment {
						/* 弹出框标题、表格标题 */
						font-family: Source Han Sans CN;
						font-style: normal;
						font-weight: normal;
						font-size: 1.3rem;
						line-height: 2rem;
						/* or 143% */
						color: #191F25;
					}
				}
			}
		}
	}
}
.fix-bottom {
  position: fixed;
  bottom: 0rem;
  left: 0;
  right: 0;
  z-index: 1;
  box-sizing: border-box;
  background: white;
  text-align: center;
  border-top: 1px solid #f4f4f4;
  padding: 0.5rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  .box {
    flex: 0 0 3.6rem;
    .icon {
      .img {
        width: 31px !important;
      }
    }
    .text {
      font-size: 1.3rem;
      color: $color3;
    }
  }
  .submitBtn {
    flex: 1;
    background-color: $mainColor;
    color: white;
    margin: 0.2rem auto;
    font-size: 1.4rem;
  }
}
.jie {
  padding: 1rem 1.6rem;
  display: flex;

  .jieLeft {
    flex: 0 0 2rem;
  }
  .jieRight {
    flex: 1;
    .title {
      font-size: 1.5rem;
      color: $color1;
    }
    .time {
      margin-top: 0.6rem;
      font-size: 1.2rem;
      color: $color2;
    }
    .links {
      .adiv {
        padding-top: 10px;
        padding-bottom: 4px;
        a {
          color: black;
        }
      }
    }
  }
}
.submitPj {
	position: absolute;
	top: 1.2rem;
	right: 2rem;
	height: 2rem;
	font-family: PingFang SC;
	font-style: normal;
	font-weight: normal;
	font-size: 1.2rem;
	line-height: 2rem;
	text-align: center;
	color: #ffffff;
}
.liuyan {
	margin-top: 5rem;
	background: #FAFAFA;
}
.liuyanban {
	position: absolute;
	top: 1.2rem;
	left: 40%;
	height: 2rem;
	font-family: PingFang SC;
	font-style: normal;
	font-weight: normal;
	font-size: 1.2rem;
	line-height: 2rem;
	text-align: center;
}
.classContainer {
  padding: 1rem 2rem;
  .title {
    /* 强调标题 */
    font-family: Source Han Sans CN;
    font-style: normal;
    font-weight: normal;
    font-size: 1.8rem;
    line-height: 2.4rem;
    color: #191F25;
  }
  .fileItem {
    display: flex;
    align-items: center;
    margin: 2rem 0;
    justify-content: space-between;
    .left {
      align-items: center;
      display: flex;
      .pic {
        margin-right: 1rem;
      }
      .desc {
        .descFont {
          /* 弹出框标题、表格标题 */
          font-family: Source Han Sans CN;
          font-style: normal;
          font-weight: normal;
          font-size: 1.4rem;
          line-height: 2rem;
          color: #191F25;
        }
        .descData {
          /* 线性按钮文字、备注文字 */
          font-family: Source Han Sans CN;
          font-style: normal;
          font-weight: normal;
          font-size: 1.2rem;
          line-height: 1.6rem;
          /* identical to box height, or 133% */
          color: rgba(25, 31, 37, 0.4);
        }
      }
    }
  }
}
</style>
<template>
  <div class="detail" v-if="course.course">
	  <div class="backIcon" @click="back"><van-icon name="arrow-left" color="#fff"/><span class="margL-s">返回首页</span></div>
    <video
      v-if="linktype == 'v' && link"
      class="video"
      :src="link"
      controls="controls"
      autoplay="autoplay"
    >
      your browser does not support the video tag
    </video>
    <div class="headerImg" v-else>
      <van-image width="100%" height="100%" fit="cover" :src="link" />
    </div>
    <!-- <img class="headerImg" :src="course.course.images" :style="{width:screenWidth+'px'}"> -->
    <div class="info">
      <div class="line1">
        <span class="title">{{ course.course.name }}</span>
        <span
          v-if="course.model"
          :class="$utils.getStatusBadge(course.model.start)"
          >{{ course.model.startname }}</span
        >
      </div>
      <div class="line2">
        <span><van-icon name="clock-o" size="1.8rem" /></span>
        <span class="text">{{ course.model.endtime }} 报名截止</span>
      </div>
      <!-- <div class="line2 margT-l">
				<span><van-icon name="location-o" size="1.9rem"/></span>
				<span class="text">{{course.class[0]||course.course.university}}</span>
			</div> -->
      <div class="line2 margT-l" v-if="course.model.sign">
        <span><van-icon name="friends-o" size="1.9rem" /></span>
        <span class="text" v-if="course.model.sign"
          >{{ course.model.sign || 0 }}人已报名</span
        >
        <span class="text" v-if="course.model.limt_number > 0">|</span>
        <span class="text2" v-if="course.model.limt_number > 0"
          >限报{{ course.model.limt_number }}人</span
        >
      </div>
      <div class="line2 margT-l">
        <span><van-icon name="location-o" size="1.8rem" /></span>
        <span class="text">{{ course.model.address }}</span>
      </div>
    </div>
    <div class="splitLine"></div>
    <div>
      <van-tabs
        v-model="tabActive"
        line-width="100"
        title-active-color="#335FFC"
        color="#335FFC"
        @change="onClickTabs"
      >
        <van-tab title="课程简介" name="0">
          <div class="content ql-editor">
            <div class="title2">课程信息</div>
            <div class="line">
              <span class="label">时间</span>
              <span class="value"
                >{{ course.course.release_time }} 至
                {{ course.course.closing_time }}</span
              >
            </div>
            <div class="line">
              <span class="label">课时</span>
              <span class="value"
                >{{ course.course.course_duration }}节课时</span
              >
            </div>
            <div class="line3" v-if="course.course.remarks">
              <div class="label">备注</div>
              <div class="value">
                {{ course.course.remarks }}
              </div>
            </div>
            <div class="line3" v-if="course.course.introduction">
              <div class="title">课程介绍</div>
              <div class="value">
                {{ course.course.introduction }}
              </div>
            </div>
            <div class="line4">
              <div class="title">课程讲师</div>
              <div
                class="item"
                v-for="(item, index) in course.teacher"
                :key="index"
              >
                <van-image
                  class="image"
                  round
                  width="3.4rem"
                  height="3.4rem"
                  fit="cover"
                  :src="item.avatar"
                />
                <div class="name">{{ item.name }}</div>
                <div class="desc">{{ item.introduction }}</div>
              </div>
            </div>
            <div class="line3" v-if="course.course.introduction">
              <div class="title">课程详情</div>
              <div class="value" v-html="course.course.content"></div>
            </div>
							<div class="line5">
								<div class="title">评价 {{totalCount}}</div>
								<div
									class="item"
									v-for="(item, index) in comment"
									:key="index"
								>
									<div class="img">
										<van-image
											class="image"
											round
											width="3.4rem"
											height="3.4rem"
											fit="cover"
											:src="item.avatar"
										/>
									</div>
									<div class="rightBox">
										<div class="fotn">
											<div class="icon" @click="reply(item)">
												<div class="fontIcon">{{item.likes}}</div>
												<img :src="item.likesa == '已点赞' ? enter : unenter" class="img">
											</div>
											<div class="name">{{ item.membername}}</div>
											<div class="desc">{{ item.content }}</div>
										</div>
										<div class="huifu" v-show="item.children.length > 0" v-for="(items, index) in item.children" :key="index">
											<div class="huifuNames">
												<div class="huifuName">{{items.username}}</div>
												<img class="userIncon" src="../../assets/img/userRen.svg"/>
											</div>
											<div class="huifuComment">{{items.content}}</div>
										</div>
									</div>
									
								</div>

							</div>
          </div>
        </van-tab>
        <van-tab title="课程表" name="1">
          <!-- <div class="jie">
					  <div class="jieLeft">01</div>
					  <div class="jieRight">
						  <div class="title">莫高窟——古丝绸路上的咽喉之地</div>
						  <div class="time">上课时间：5月1日(周二) 9:00-9:40</div>
					  </div>
				  </div> -->
          <van-collapse v-if="course.course.type == 1" v-model="activeNames">
            <van-collapse-item
              v-for="(item, index) in coursesMulu"
              :key="index"
              :title="`第${index + 1}章 ${item.title}`"
              :name="index"
            >
              <div
                class="jie"
                :class="active == item.id ? 'active' : ''"
                v-for="(item, index) in item.children"
                :key="index"
              >
                {{ index + 1 }} {{ item.titles }}
              </div>
            </van-collapse-item>
          </van-collapse>
          <div v-if="course.course.type == 2">
            <!-- <div class="jie" v-for="(item,index) in coursesMulu" :key="index">{{index+1}} {{item.title}}</div> -->
            <div class="jie" v-for="(item, index) in coursesMulu" :key="index">
              <div class="jieLeft">
                {{ index + 1 < 10 ? "0" + (index + 1) : index + 1 }}
              </div>
              <div class="jieRight">
                <div class="title">{{ item.title }}</div>
                <div class="time">{{ item.startclasstime }}</div>
                <div
                  class="links"
                  v-for="(item, index) in item.link"
                  :key="index"
                >
                  <!-- <div class="adiv">
                    <a :href="item" target="_blank">附件{{ index + 1 }}</a>
                  </div> -->
                </div>
                <!-- <div class="time">上课时间：5月1日(周二) 9:00-9:40</div> -->
              </div>
            </div>
          </div>
        </van-tab>
        <van-tab title="课件" name="2">
          <div class="classContainer">
            <div class="title">课程信息</div>
            <div class="fileItem" v-for="item in linkAddress" :key="item.uid">
              <div class="left">
                <div class="pic">
                  <!-- <img src="../../assets/img/pdf.svg" alt="" v-if="item.type == 'application/vnd.ms-excel'"> -->
                  <img src="../../assets/img/pdf.svg" alt="" v-if="item.type == ''">
                  <img src="../../assets/img/word.svg" alt="" v-else-if="item.type == 'application/msword'">
                  <img src="../../assets/img/other.svg" alt="" v-else>
                </div>
                <div class="desc">
                  <div class="descFont">{{item.name}}</div>
                  <div class="descData">{{(item.size / 1024 / 1024).toFixed(2)}}MB | {{$utils.parseToDateAll(item.lastModifiedDate)}}</div>
                </div>
              </div>
              <div class="right"  @click="onclickitem(item)">
                <img src="../../assets/img/downlo.svg" alt="">
              </div>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
    <div class="tabbar-height-white"></div>
    <div class="fix-bottom">
      <div
        class="box"
        @click="CollectH5Saves(course.course.id)"
        v-if="fromView != 1"
      >
        <span class="icon">
          <img
            class="img"
            v-if="collect == false"
            src="../../assets/img/star_unactive.svg"
            alt=""
          />
          <img
            class="img"
            v-else
            src="../../assets/img/star_active.svg"
            alt=""
          />
        </span>
        <span class="text"> 收藏 </span>
      </div>
      <div class="box margL-l margR-l" @click="shareEvent" v-if="fromView != 1">
        <span class="icon">
          <img style="width: 39px" src="../../assets/img/wechat.svg" alt="" />
        </span>
        <span class="text"> 分享 </span>
      </div>

      <van-button
        round
        block
        plain
        v-if="fromView == 1"
        @click="pingjia"
        style="margin-left: 5px;color:blue !important; border-color:blue !important; border-radius: 22px"
        >评价</van-button
      >
      <van-button
        round
        block
        type="info"
        v-if="fromView == 1"
        @click="scanQRCode"
        style="margin-left: 5px; border-radius: 22px"
        >扫码签到</van-button
      >
      <div style="width: 100%" v-else>
        <van-button
          round
          block
          class="submitBtn"
          v-if="applyStatus == '报名结束'"
          :disabled="applyStatus == '报名结束'"
          >报名已结束</van-button
        >
        <van-button
          round
          block
          class="submitBtn"
          v-else-if="applyStatus == '已报名'"
          :disabled="applyStatus == '已报名'"
          >已报名</van-button
        >
        <van-button
          round
          block
          class="submitBtn"
          v-else
          @click="toApplyView(course.course.id)"
          :disabled="course.model.start == 1 || course.model.status == 2"
          >我要报名</van-button
        >
      </div>
    </div>
    <!-- 评论 -->
    <van-popup
      v-model="show"
      closeable
			round
      :close-on-click-overlay="false"
      close-icon-position="top-left"
      position="bottom"
      :style="{ height: '50%' }"
    >
			<span class="liuyanban">写留言</span>
      <van-button type="info" class="submitPj" @click="subTijiao">提交</van-button>
			<van-field
				class="liuyan"
				v-model="message"
				rows="5"
				autosize
				type="textarea"
				placeholder="留言审核通过后，将对所有人可见"
			/>
    </van-popup>
  </div>
</template>

<script>
import { Toast } from "vant";
// @ is an alias to /src
import SearchBox from "@/components/SearchBox.vue";
import { myMixins } from "@/assets/js/mixins.js";
const enter = require('../../assets/img/reply.svg')
const unenter = require('../../assets/img/unreply.svg')
export default {
  name: "course",
  mixins: [myMixins],
  components: {
    SearchBox,
  },
  data() {
    return {
      // 可见数据
      linkAddress: [],
      enter: enter,
      unenter: unenter,
      totalCount: 0,
			// 留言内容
			message: '',
			// 数据
			comment: [],
      // 显示隐藏
      show: false,
      linktype: "i",
      link: "",
      tabActive: 0,
      course: "",
      fromView: "",
      coursesMulu: "",
      activeNames: [],
      applyStatus: "",
      collect: "",
      model: "",
      screenWidth: "",
    };
  },
  created() {
	const url = (location.href)
	// const testhref = `//${url.split('?')[0]}#${url.split('#')[1]}&time=${new Date().getTime()}`
	// console.log('testhref',testhref)
    const _this = this;
	//  || this.$store.state.openid
	this.openid = localStorage.getItem("openid");
	console.log("====this.openid======",this.openid)
	if (this.openid) {
		//_this.deleteurlCode
	  if(url.indexOf('code')>0){
	  	this.$router.push(`${url.split('#')[1]}`)
	  }else{
		  const campus = JSON.parse(localStorage.getItem("selectedCampus"));
		  if (!campus) {
		    const fromView = location.href.split('#')[1];
			console.log("====toSelectCampus======")
			console.log("====location.href======",location.href)
			console.log("====fromView======",fromView)
			localStorage.setItem('from',fromView)
		    this.$router.push(`/selectCampus?from=${fromView}`);
		  }
	  }
	}else{
		// const url = (location.href)
		// if(url.indexOf('code')>0){
		// 	localStorage.setItem('isReload',1)
		// 	this.$router.push(`${url.split('#')[1]}`)
		// 	console.log("======getWeixinConfig========")
		// 	_this.getWeixinConfig()
		// }
	  if(process.env.NODE_ENV == 'production'){
	    console.log("getWeixinConfig")
	    _this.getWeixinConfig()
		return
	  }
	}
	// setTimeout(()=>{
	// 	const url = (location.href)
	// 	if(url.indexOf('code')>0){
	// 		this.$router.push(`${url.split('#')[1]}`)
	// 	}
	// },1000)
    
    // 获取页面宽度
    this.screenWidth = window.screen.width; //整个屏幕的宽度
    console.log("screenWidth", this.screenWidth);
  },
  // destroyed() {
  // 	if(this.$route.query.fromView=='s'){
  // 		console.log("-2")
  // 		this.$router.go(-2)
  // 	}
  // },
  mounted() {
    const id = this.$route.query.id;
    const type = this.$route.query.type;
    this.fromView = this.$route.query.fromView;
	console.log(id, "id_course");
    console.log(this.fromView, "fromvView");
    this.CoursesDetail(id, type);
    this.getApplyInfoByItem();
    this.CollectH5Items();

	if(JSON.parse(localStorage.getItem("selectedCampus"))&&JSON.parse(localStorage.getItem("selectedCampus")).id){
		this.$request.sGuestbook({course_id: this.$route.query.id, checkstatus: 1, openid: this.$store.state.openid || localStorage.getItem("openid"), campus: JSON.parse(localStorage.getItem("selectedCampus")).id,}).then(res => {
			this.comment = res.data.data
			// this.comment.map(item => {
			//   this.isSureEnter(item.id)
			// })
			this.totalCount = res.data.totalCount
		})
	}
  },

  methods: {
	 
    onclickitem(item) {
      window.open(item.response.data.url)
    },

    reply(item) {
      let params = {
        id: item.id,
        likes: 1,
        openid: this.$store.state.openid || localStorage.getItem("openid"),
        campus: JSON.parse(localStorage.getItem("selectedCampus")).id,
      };
      // 利用插件防抖
      Toast.loading({
        message: '加载中...',
        forbidClick: true
      });
      this.$request.getGuestbook(params).then(res => {
        this.$request.sGuestbook({course_id: this.$route.query.id, checkstatus: 1, openid: this.$store.state.openid || localStorage.getItem("openid"), campus: JSON.parse(localStorage.getItem("selectedCampus")).id,}).then(res => {
          this.comment = res.data.data
          this.totalCount = res.data.totalCount
          Toast.clear()
        })
      })
    },
	// 保存
	subTijiao() {
		let params = {
			course_id: this.$route.query.id,
			openid: this.$store.state.openid || localStorage.getItem("openid"),
			campus: JSON.parse(localStorage.getItem("selectedCampus")).id,
					content: this.message
		  };
		this.$request.getGuestbook(params).then(res => {
			console.log(res)
			this.show = false
			Toast('已留言，等待审核中~')
		})
	},
    // 评价
    pingjia() {
      this.show = true;
    },
    changeLink(item) {
      if (item) {
        this.link = item;
      } else {
        this.link = null;
      }

      if (this.link.indexOf("jpg") > -1 || this.link.indexOf("png") > -1) {
        this.linktype = "i";
      } else {
        this.linktype = "v";
      }
      console.log("link", this.link);
    },
    toApplyView(id) {
      console.log("this.model", this.model);
      localStorage.setItem("model", JSON.stringify(this.model.valueclo));
      this.toView(`/course/apply?course_id=${id}&model_id=${this.model.id}`);
    },
    scanQRCode() {
      const _this = this;
      const url = (location.href.split('#')[0])
      let params = {
          url: url
      }
      _this.$request.configJssdk(params).then(res=>{
        if(res.ret == 200) {
          wx.config({
            debug: false,// 是否开启调试模式
            appId: res.data.appId,//appid
            timestamp: res.data.timestamp,// 时间戳
            nonceStr: res.data.nonceStr,// 随机字符串
            signature: res.data.signature,// 签名
            jsApiList: ['scanQRCode']// 需要使用的JS接口列表
          })
          wx.scanQRCode({
            desc: 'scanQRCode desc',
            needResult: 0, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            scanType: ['qrCode'], // barCode\qrCode可以指定扫二维码还是一维码，默认二者都有
            success: function (res) {
              //alert(res.resultStr);
            }
          });
        }else{
          Toast('configJssdk error')
        }
      })
    },
    // scanQRCode() {
    //   const _this = this;
    //   wx.scanQRCode({
    //     desc: 'scanQRCode desc',
    //     needResult: 0, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
    //     scanType: ['qrCode'], // barCode\qrCode可以指定扫二维码还是一维码，默认二者都有
    //     success: function (res) {
    //       //alert(res.resultStr);
    //     }
    //   });
    // },
    CollectH5Items() {
      const _this = this;
      let params = {
        course_id: this.$route.query.id,
        openid: localStorage.getItem("openid") || this.$store.state.openid,
        campus_id: JSON.parse(localStorage.getItem("selectedCampus")).id,
      };
      _this.$request.CollectH5Items(params).then((res) => {
        if (res.ret == 200) {
          this.collect = res.data;
        }
      });
    },
    weixinShareTimeline(item) {
      WeixinJSBridge.invoke("updateAppMessageShareData", item);
    },
    // shareEvent() {
    // 	const item = {
    // 		title:'title',
    // 		desc:'desc',
    // 		link:'link',
    // 		imgUrl:'www.baidu.com'
    // 	}
    // 	this.weixinShareTimeline(item)
    // },
    CollectH5Saves() {
      const _this = this;
      let params = {
        course_id: this.$route.query.id,
        openid: this.$store.state.openid || localStorage.getItem("openid"),
        campus_id: JSON.parse(localStorage.getItem("selectedCampus")).id,
      };
      console.log("CollectH5Saves", params);
      _this.$request.CollectH5Saves(params).then((res) => {
        if (res.ret == 200) {
          Toast("操作成功");
          _this.CollectH5Items();
        }
      });
    },
    getApplyInfoByItem() {
      const _this = this;
      let params = {
        id: this.$route.query.id,
        openid: localStorage.getItem("openid") || this.$store.state.openid,
        campus: JSON.parse(localStorage.getItem("selectedCampus")).id,
        model_id: this.model.id,
      };
      console.log("getApplyInfoByItem", params);
      _this.$request.getApplyInfoByItem(params).then((res) => {
        this.applyStatus = res.data;
      });
    },
    CoursesItem() {
      const _this = this;
      let params = {
        id: this.course.course.id,
      };
      console.log("CoursesItem", params);
      _this.$request.CoursesItem(params).then((res) => {
        let coursesMulu = res.data;
        coursesMulu.map((item, index) => {
          const y_m = _this.$utils.parseToDateMD(item.start_time);
          const hm_hm = `${_this.$utils.parseToDateHM(
            item.start_time
          )}-${_this.$utils.parseToDateHM(item.end_time)}`;
          item.startclasstime = `${y_m} ${hm_hm}`;
          return item;
        });
        _this.coursesMulu = coursesMulu;
      });
    },
    
    CoursesDetail(id, type) {
      const _this = this;
      let params = {
        id: id,
        type: type,
        campus: JSON.parse(localStorage.getItem("selectedCampus")).id,
        campus_id: JSON.parse(localStorage.getItem("selectedCampus")).id,
      };
      _this.$request.CoursesDetail(params).then((res) => {
        if (res.ret == 200) {
          this.course = res.data;
          if(res.data.link) {
            this.linkAddress = res.data.link[0]
          }
          console.log(this.linkAddress)
          this.link = this.course.course.images;
          console.log('this.link', this.link)
          this.model = res.data.model;
          this.getApplyInfoByItem();
          this.shareThisPage(this.course.course);
          
          // let u = navigator.userAgent;
          // let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
          // let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
          // if (isAndroid) {
          //   //这个是安卓操作系统
            
          // }
          // if (isIOS) {
          //   //这个是ios操作系统
          // }

          if (this.fromView == 1) {
            //是签到页面，从我的课程进来的
            document.title = this.course.course.name;
          }
          this.$forceUpdate();
        }
        // this.$store.commit('setCaseList', this.caseList);
      });
    },
    onClickTabs(index) {
      console.log("onClickTabs", index);
      this.active = index;
      if (index == 0) {
        //全部
      } else if (index == 1) {
        //线下课程
        this.CoursesItem();
      }
    },
    getActivityPage() {
      const _this = this;
      let params = {
        status: 2,
        pageNo: _this.pageNo,
        pageSize: _this.pageSize,
      };
      _this.$request
        .getActivityPage(params)
        .then((res) => {
          let data = res.data.data;
          _this.list.push(...data);
          console.log(_this.list.length);
          if (_this.pageNo >= Math.ceil(res.data.totalCount / _this.pageSize)) {
            _this.finished = true;
          } else {
            _this.pageNo++;
          }
          // this.$store.commit('setCaseList', this.caseList);
        })
        .finally(() => {
          console.log("finally");
        });
    },
  },
};
</script>
